import Vue from 'vue'
import VueRouter from 'vue-router'

import SStorage from '@/common/utils/sessionStorage'
import { basePath } from '@/common/config/pathConfig'
Vue.use(VueRouter);


//管网信息管理
const pipeNet_route = r => require.ensure([], r => (require("@/pages/pipeNet_msg/main_route")), '管网分路由');
const pipeNet_home = r => require.ensure([], r => (require("@/pages/pipeNet_msg/index")), '管网首页');
const pipeNet_msg = r => require.ensure([], r => (require("@/pages/pipeNet_msg/msg")), '管网综合信息');
const pdfView = r => require.ensure([], r => (require("@/pages/pipeNet_msg/preview")), '预览pdf');

const pipeNet_msgAnalysis = r => require.ensure([], r => (require("@/pages/pipeNet_msg/msg_analysis")), '管网信息统计');
const pipeNet_waterInformation = r => require.ensure([], r => (require("@/pages/pipeNet_msg/waterInformation")), '大用户用水信息');
const infoTable = r => require.ensure([], r => (require("@/pages/pipeNet_msg/infoTable")), '特定大用户用水信息详细表格');
const pipeNet_bagUser_manage = r => require.ensure([], r => (require("@/pages/pipeNet_msg/bagUser_manage")), '大用户用水管理');
//管网监测管理


//404页面
const noFound = r => require.ensure([], r => (require("@/pages/404")), '404页面');

let routes = [
    {
        path: "/",
        redirect: "/pipe/pipeNet_route"
    },
    {
        path: '/pipe/pipeNet_route', //管网信息管理
        component: pipeNet_route,
        name: 'pipeNet_route',
        redirect: '/pipe/pipeNet_route/pipeNet_home',
        children: [{
            path: '/pipe/pipeNet_route/pipeNet_home',
            component: pipeNet_home,
            name: 'pipeNet_home'
        }, {
            path: '/pipe/pipeNet_route/pipeNet_msg',
            component: pipeNet_msg,
            name: 'pipeNet_msg'
        },
        {
            path: '/pipe/pipeNet_route/pipeNet_msg/pdfView',
            component: pdfView,
            name: 'pdfView'
        },
        {
            path: '/pipe/pipeNet_route/pipeNet_msgAnalysis',
            component: pipeNet_msgAnalysis,
            name: 'pipeNet_msgAnalysis'
        },
        {
            path: '/pipe/pipeNet_route/pipeNet_bagUser_manage',
            component: pipeNet_bagUser_manage,
            name: 'pipeNet_bagUser_manage'
        }, {
            path: '/pipe/pipeNet_route/pipeNet_waterInformation',
            component: pipeNet_waterInformation,
            name: 'pipeNet_waterInformation'
        }, {
            path: '/pipe/pipeNet_route/pipeNet_waterInformation/infoTable',
            component: infoTable,
            name: 'infoTable'
        }
        ]
    },
    {
        path: '/pipe/monitor', //管网监测管理
        redirect: '/pipe/monitor/surver',
        component: resolve => require(['@/pages/monitor/menu'], resolve),
        children: [{
            path: '/pipe/monitor/surver',
            component: resolve => require(['@/pages/monitor/surver'], resolve),
            name: 'pipe_monitor_surver'
        }, {
            path: '/pipe/monitor/earlyWarning',
            component: resolve => require(['@/pages/monitor/earlyWarning'], resolve),
            name: 'pipe_monitor_earlyWarning'
        },
        {
            path: '/pipe/monitor/waterStatiastics',
            component: resolve => require(['@/pages/monitor/waterStatiastics'], resolve),
            name: 'pipe_monitor_waterStatiastics'
        },
        {
            path: '/pipe/monitor/baseSet',
            component: resolve => require(['@/pages/monitor/baseSet'], resolve),
            name: 'pipe_monitor_baseSet'
        },
        {
            path: '/pipe/monitor/dispatch',
            component: resolve => require(['@/pages/monitor/dispatch'], resolve),
            name: 'pipe_monitor_dispatch'
        }
        ]
    },
    {
        path: '/pipe/leaktest', //分区计量检漏管理
        redirect: '/pipe/leaktest/zoning_leakDetection',
        component: resolve => require(['@/pages/leaktest/menu'], resolve),
        children: [
            {
                path: '/pipe/leaktest/zoning_leakDetection',  //分区计量检漏
                component: resolve => require(['@/pages/leaktest/zoning_leakDetection'], resolve),
                name: 'pipe_leaktest_zoning_leakDetection'
            },
            {
                path: '/pipe/leaktest/monitorWarning',//监测预警
                component: resolve => require(['@/pages/leaktest/monitorWarning'], resolve),
                name: 'pipe_leaktest_monitorWarning'
            },
            {
                path: '/pipe/leaktest/partitionConfig', //分区配置
                component: resolve => require(['@/pages/leaktest/partitionConfig'], resolve),
                name: 'pipe_leaktest_partitionConfig'
            }
        ]
    },
    {
        path: '/pipe/rushrepair', //管网巡检抢修管理
        redirect: '/pipe/rushrepair/information',
        component: resolve => require(['@/pages/rushrepair/menu'], resolve),
        children: [{
            path: '/pipe/rushrepair/information', //综合信息
            component: resolve => require(['@/pages/rushrepair/information'], resolve),
            name: 'pipe_rushrepair_information',
        },
        {
            path: '/pipe/rushrepair/hiddenDanger',//隐患管理
            component: resolve => require(['@/pages/rushrepair/hiddenDanger'], resolve),
            name: 'pipe_rushrepair_hiddenDanger',
        },
        {
            path: '/pipe/rushrepair/repair',//检修管理
            component: resolve => require(['@/pages/rushrepair/repair'], resolve),
            name: 'pipe_rushrepair_repair'
        },
        {
            path: '/pipe/rushrepair/statistic',//统计管理
            component: resolve => require(['@/pages/rushrepair/statistic'], resolve),
            name: 'pipe_rushrepair_statistic'
        }]
    },
    {
        path: '*',
        component: noFound,
        name: 'noFound'
    },
    {
        path: '/test/layer',
        component: resolve => require(['@/pages/test/containers/Gis'], resolve),
        name: 'layer'
    },
    {
        path: '/test/toggleBaseMap',//切换图层
        component: resolve => require(['@/pages/test/containers/ToggleBaseMap'], resolve),
        name: 'toggleBaseMap'
    },
    {
        path: '/test/rangeLength',//测量距离
        component: resolve => require(['@/pages/test/containers/RangeLength'], resolve),
        name: 'rangeLength'
    }
]

// let routes=[];
let router = new VueRouter({
    mode: 'hash',
    base: basePath,
    routes
})



export default router
// router.beforeEach((route, redirect, next) => {

// let user = SStorage.get('user');
// if (!user && route.path !== '/login') {
//     window.location.href = "注册登录首页"
// } else {
//     if (route.name) {
//         next()
//     } else {
//         next({ name: 'noFound' })
//     }
// }
// }